package com.ai.entity.function;

import com.ai.entity.BasePage;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;

@Data
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FunctionPage extends BasePage<FunctionPO> {

    private Integer id;
    private String nickname;
    private Integer type;

    @Override
    public QueryWrapper<FunctionPO> getQuery(QueryWrapper<FunctionPO> queryWrapper) {
        return super.getQuery(queryWrapper)
                .like((!StringUtils.isEmpty(nickname)), "nickname", nickname)
                .eq((type != null && type != 0), "type", type)
                .eq("state", 1)
                .ge((!com.alibaba.druid.util.StringUtils.isEmpty(getDatebegin())), "functions.create_time", getDatebegin())
                .lt((!com.alibaba.druid.util.StringUtils.isEmpty(getDateend())), "functions.create_time", getDateend())
                .orderByDesc("functions.create_time");
    }
}
